import http from '@/utils/http'
import { useAuthStore } from '@/store/auth'
import { storeToRefs } from 'pinia'

const authStore = useAuthStore()
const { globalParams, historyParams } = storeToRefs(authStore)
// 获取人员类型数量
export const getPersonTypeCount = () => {
  return http.postOrJson('/jzry/peopleCountByType', { ...globalParams.value })
}

// 获取井下人数统计
export const getPersonCount = () => {
  return http.get('/jzry/ryssCount', { params: { ...globalParams.value ,...historyParams.value } })
}

// 获取井下人员时间轴
export const getPersonTimeAxis = () => {
  return http.postOrJson('/jzry/ryssTimeAxi', { ...globalParams.value })
}

// 获取下井人员实时数据
export const getPersonList = (params: any) => {
  if (globalParams.value.startTime) {
    return http.postOrJson('/jzry/his/dataList', { ...globalParams.value, ...params })
  }
  return http.postOrJson('/jzry/ryssList', { ...globalParams.value, ...params })
}

// 根据人员名称查询人员信息
export const getPersonInfoByName = (name: string) => {
  return http.get('/jzry/peopleInfoByName', { params: { customerNo: globalParams.value.customerNo, name } })
}

// 获取井下人员轨迹数据
export const getPersonTrackData = (inWellTime: string, peopleNo: string, outWellTime?: string) => {
  return http.postOrJson('/jzry/track/dataList', {
    customerNo: globalParams.value.customerNo,
    inWellTime,
    peopleNo,
    outWellTime
  })
}


// 获取人员数据
export const getPersonData = (searchData) => {
  return http.postOrJson('/jzry/getPeopleData', searchData)
}


export const getAlarmPeopleByAreaId = () => {
  return http.get('/jzry/getAlarmPeopleByAreaId', { params: { ...globalParams.value, beginTime: globalParams.value.startTime } })
}